<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp" %>
<form:form id="inputForm" action="${ctx}/adoms/departmentType/save" method="post" cssClass="well form-inline"
           commandName="departmentType">
    <input type="hidden" name="id" value="${departmentType.id}"/>
    <table class="table table-striped table-bordered table-condensed">
        <thead>
        <i class="icon-flag"></i>
        <strong>部门类型表单</strong>
        </thead>
        <tr>
            <td>部门类型:</td>
            <td>
                <form:input path="name"/>
                <form:errors path="name" cssClass="error"></form:errors>
            </td>
        </tr>
        <tr>
            <td>备注:</td>
            <td>
                <form:textarea path="memo" rows="4" cssClass="span6"/>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input class="btn" type="submit" value="提交"/>
                &nbsp;
                <input class="btn" type="button" value="返回" back="back"/>
            </td>
        </tr>
    </table>
</form:form>
<script>
    $(document).ready(function () {
        //聚焦第一个输入框
        $("#name").focus();
        //为inputForm注册validate函数
        $("#inputForm").validate({
            rules: {
                name: {
                    required: true,
                    remote: {
                        type: "POST",
                        url: "${ctx}/adoms/departmentType/repeat",
                        data: {
                            account: function () {
                                return $.trim($("#name").val());
                            },
                            id: ${departmentType.id == null ? 0:departmentType.id}
                        }
                    }
                },
                memo: "required"
            },
            messages: {
                name: {
                    remote: "部门类型重复"
                }
            }
        });
    });
</script>